package com.jzlin.funhub.admin.controller;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jzlin.funhub.admin.model.dto.ArticlePageDTO;
import com.jzlin.funhub.framework.core.http.RestRet;
import com.jzlin.funhub.framework.utils.RedisUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *  开发者接口
 *
 * @author jzlin
 * @since 2025-07-17
 */
@RestController
@Api(tags = {"开发者接口"})
@RequestMapping("/dev")
public class DevController {

    @Autowired
    private RedisUtil redisUtil;

    @ApiOperation("清理缓存")
    @PostMapping("/cache/clear")
    public RestRet<IPage<ArticlePageDTO>> clearCache(String key) {
        redisUtil.deleteByPattern(StrUtil.isBlank(key) ? "*" : key);
        return RestRet.createSuccessRet();
    }
}
